public class ThreadDemo9 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{
            while(!Thread.currentThread().isInterrupted()){
                System.out.println("Thread\n");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    //1.抛出异常之后，真正结束了
                    //throw new RuntimeException(e);

                    //2.没有做到真正结束，抛出异常之后，仍旧执行
                    e.printStackTrace();
                }
            }
        });

        t.start();   

        System.out.println("结束t线程\n");
        Thread.sleep(3000);
        t.interrupt();
    }
}
